package com.qf.student.bo;

import com.qf.student.utils.StringUtils;

/**
 * @author YaoJiXing
 * created 2022/11/23 22:31
 */
public class CheckTimeBo {

    public static boolean timeConflict(String exists, String choose) {
        String[] existSplit = exists.split("-");
        String[] chooseSplit = choose.split("-");

        int existDay = StringUtils.str2num(existSplit[0]);
        int chooseDay = StringUtils.str2num(chooseSplit[0]);

        int existsStart = StringUtils.str2num(existSplit[1]);
        int chooseStart = StringUtils.str2num(chooseSplit[1]);

        int existsCount = StringUtils.str2num(existSplit[2]);
        int chooseCount = StringUtils.str2num(chooseSplit[2]);

        if (existDay != chooseDay) {
            return false;
        }

        if (existsStart > chooseStart) {
            if (existsStart >= (chooseStart + chooseCount)) {
                return false;
            }
        }

        if (chooseStart > existsStart) {
            if (chooseStart >= (existsStart + existsCount)) {
                return false;
            }
        }

        return true;
    }

}
